﻿using Cart.Bll;
using Cart.model;
using Microsoft.Ajax.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Cart.Api.Controllers
{
    public class loginController : ApiController
    {
        // GET: api/login
        UserBLL bll = new UserBLL();
        
        public ResultData<UsersDto> Get( string name, string pwd)
        {
            var dsd = bll.getuser(name,pwd);

            var ob = from n in  dsd
                 select new  UsersDto
                 {
                  userID=n.userID,
                   birthday=n.birthday,
                    name=n.name,
                        phone=n.phone,
                         pwd=n.pwd, 
                          roleID=n.roleID
                 };
            ResultData<UsersDto> re = new ResultData<UsersDto>();
            re.data =ob.FirstOrDefault();
            re.code = dsd != null ? 1 : 0;
            re.msg = dsd != null ? "ok" : "error";
            return re;
        }

  
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/login
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/login/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/login/5
        public void Delete(int id)
        {
        }
    }
}
